<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>课程评价系统 - 管理员</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="../css/style.css" rel="stylesheet">
</head>
<body>
    <!-- 导航栏 -->
    <nav class="navbar navbar-expand-lg navbar-light bg-white">
        <div class="container">
            <a class="navbar-brand" href="#">课程评价系统</a>
            <div class="d-flex align-items-center">
                <span class="me-3" id="userName"></span>
                <button class="btn btn-outline-danger btn-sm" onclick="utils.logout()">退出</button>
            </div>
        </div>
    </nav>

    <!-- 主要内容 -->
    <div class="container my-4">
        <!-- 统计卡片 -->
        <div class="row mb-4">
            <div class="col-md-2">
                <div class="card stat-card">
                    <div class="card-body">
                        <h6 class="card-subtitle mb-2 text-muted">学生总数</h6>
                        <h2 class="card-title" id="studentCount">0</h2>
                    </div>
                </div>
            </div>
            <div class="col-md-2">
                <div class="card stat-card">
                    <div class="card-body">
                        <h6 class="card-subtitle mb-2 text-muted">教师总数</h6>
                        <h2 class="card-title" id="teacherCount">0</h2>
                    </div>
                </div>
            </div>
            <div class="col-md-2">
                <div class="card stat-card">
                    <div class="card-body">
                        <h6 class="card-subtitle mb-2 text-muted">课程总数</h6>
                        <h2 class="card-title" id="courseCount">0</h2>
                    </div>
                </div>
            </div>
            <div class="col-md-2">
                <div class="card stat-card">
                    <div class="card-body">
                        <h6 class="card-subtitle mb-2 text-muted">班级总数</h6>
                        <h2 class="card-title" id="classCount">0</h2>
                    </div>
                </div>
            </div>
            <div class="col-md-2">
                <div class="card stat-card">
                    <div class="card-body">
                        <h6 class="card-subtitle mb-2 text-muted">评价总数</h6>
                        <h2 class="card-title" id="evaluationCount">0</h2>
                    </div>
                </div>
            </div>
            <div class="col-md-2">
                <div class="card stat-card">
                    <div class="card-body">
                        <h6 class="card-subtitle mb-2 text-muted">平均评分</h6>
                        <h2 class="card-title" id="averageScore">0.0</h2>
                    </div>
                </div>
            </div>
        </div>

        <!-- 选项卡 -->
        <ul class="nav nav-tabs mb-4" id="adminTabs" role="tablist">
            <li class="nav-item" role="presentation">
                <button class="nav-link active" id="students-tab" data-bs-toggle="tab" data-bs-target="#students" type="button" role="tab">学生管理</button>
            </li>
            <li class="nav-item" role="presentation">
                <button class="nav-link" id="courses-tab" data-bs-toggle="tab" data-bs-target="#courses" type="button" role="tab">课程管理</button>
            </li>
            <li class="nav-item" role="presentation">
                <button class="nav-link" id="classes-tab" data-bs-toggle="tab" data-bs-target="#classes" type="button" role="tab">班级管理</button>
            </li>
            <li class="nav-item" role="presentation">
                <button class="nav-link" id="enrollment-tab" data-bs-toggle="tab" data-bs-target="#enrollment" type="button" role="tab">选课管理</button>
            </li>
        </ul>

        <!-- 选项卡内容 -->
        <div class="tab-content" id="adminTabContent">
            <!-- 学生管理 -->
            <div class="tab-pane fade show active" id="students" role="tabpanel">
                <div class="card">
                    <div class="card-body">
                        <div class="d-flex justify-content-between align-items-center mb-4">
                            <h5 class="card-title mb-0">学生列表</h5>
                            <button class="btn btn-primary btn-sm" data-bs-toggle="modal" data-bs-target="#addStudentModal">添加学生</button>
                        </div>
                        <div id="studentMessage" class="alert alert-danger d-none"></div>
                        <div class="table-responsive">
                            <table class="table table-hover">
                                <thead>
                                    <tr>
                                        <th>学号</th>
                                        <th>姓名</th>
                                        <th>专业</th>
                                        <th>角色</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody id="studentList"></tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>

            <!-- 课程管理 -->
            <div class="tab-pane fade" id="courses" role="tabpanel">
                <div class="card">
                    <div class="card-body">
                        <div class="d-flex justify-content-between align-items-center mb-4">
                            <h5 class="card-title mb-0">课程列表</h5>
                            <button class="btn btn-primary btn-sm" data-bs-toggle="modal" data-bs-target="#addCourseModal">添加课程</button>
                        </div>
                        <div id="courseMessage" class="alert alert-danger d-none"></div>
                        <div class="table-responsive">
                            <table class="table table-hover">
                                <thead>
                                    <tr>
                                        <th>课程编号</th>
                                        <th>课程名称</th>
                                        <th>学分</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody id="courseList"></tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>

            <!-- 班级管理 -->
            <div class="tab-pane fade" id="classes" role="tabpanel">
                <div class="card">
                    <div class="card-body">
                        <div class="d-flex justify-content-between align-items-center mb-4">
                            <h5 class="card-title mb-0">教学班列表</h5>
                            <button class="btn btn-primary btn-sm" data-bs-toggle="modal" data-bs-target="#addClassModal">添加教学班</button>
                        </div>
                        <div id="classMessage" class="alert alert-danger d-none"></div>
                        <div class="table-responsive">
                            <table class="table table-hover">
                                <thead>
                                    <tr>
                                        <th>班级编号</th>
                                        <th>课程名称</th>
                                        <th>教师姓名</th>
                                        <th>学期</th>
                                        <th>时间地点</th>
                                        <th>评价统计(数量/平均分)</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody id="classList"></tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
            
            <!-- 选课管理 -->
            <div class="tab-pane fade" id="enrollment" role="tabpanel">
                <div class="card">
                    <div class="card-body">
                        <div class="d-flex justify-content-between align-items-center mb-4">
                            <h5 class="card-title mb-0">选课记录</h5>
                            <button class="btn btn-primary btn-sm" data-bs-toggle="modal" data-bs-target="#addStudentClassModal">添加选课记录</button>
                        </div>
                        <div class="alert alert-info">
                            <strong>提示：</strong>当前系统中有效的班级ID为 1, 2, 3。请在添加选课记录时使用这些班级ID。
                        </div>
                        <div id="enrollmentMessage" class="alert alert-danger d-none"></div>
                        <div class="table-responsive">
                            <table class="table table-hover">
                                <thead>
                                    <tr>
                                        <th>学号</th>
                                        <th>学生姓名</th>
                                        <th>班级编号</th>
                                        <th>课程名称</th>
                                        <th>选课时间</th>
                                        <th>评价状态</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody id="enrollmentList"></tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- 添加学生模态框 -->
    <div class="modal fade" id="addStudentModal" tabindex="-1">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">添加学生</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
                </div>
                <div class="modal-body">
                    <div id="addStudentMessage" class="alert alert-danger d-none"></div>
                    <form id="addStudentForm">
                        <div class="mb-3">
                            <label for="studentId" class="form-label">学号</label>
                            <input type="text" class="form-control" id="studentId" required>
                        </div>
                        <div class="mb-3">
                            <label for="studentName" class="form-label">姓名</label>
                            <input type="text" class="form-control" id="studentName" required>
                        </div>
                        <div class="mb-3">
                            <label for="studentMajor" class="form-label">专业</label>
                            <input type="text" class="form-control" id="studentMajor" required>
                        </div>
                        <div class="mb-3">
                            <label for="studentPassword" class="form-label">密码</label>
                            <input type="password" class="form-control" id="studentPassword" required>
                        </div>
                        <button type="submit" class="btn btn-primary">提交</button>
                    </form>
                </div>
            </div>
        </div>
    </div>

    <!-- 添加课程模态框 -->
    <div class="modal fade" id="addCourseModal" tabindex="-1">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">添加课程</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
                </div>
                <div class="modal-body">
                    <div id="addCourseMessage" class="alert alert-danger d-none"></div>
                    <form id="addCourseForm">
                        <div class="mb-3">
                            <label for="courseId" class="form-label">课程编号</label>
                            <input type="text" class="form-control" id="courseId" required>
                        </div>
                        <div class="mb-3">
                            <label for="courseName" class="form-label">课程名称</label>
                            <input type="text" class="form-control" id="courseName" required>
                        </div>
                        <div class="mb-3">
                            <label for="courseCredit" class="form-label">学分</label>
                            <input type="number" class="form-control" id="courseCredit" min="1" max="10" required>
                        </div>
                        <button type="submit" class="btn btn-primary">提交</button>
                    </form>
                </div>
            </div>
        </div>
    </div>

    <!-- 添加选课记录模态框 -->
    <div class="modal fade" id="addStudentClassModal" tabindex="-1">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">添加选课记录</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
                </div>
                <div class="modal-body">
                    <div id="addStudentClassMessage" class="alert alert-danger d-none"></div>
                    <form id="addStudentClassForm">
                        <div class="mb-3">
                            <label for="scStudentId" class="form-label">学号</label>
                            <select class="form-control" id="scStudentId" required>
                                <option value="">请选择学生</option>
                            </select>
                        </div>
                        <div class="mb-3">
                            <label for="scClassId" class="form-label">教学班</label>
                            <select class="form-control" id="scClassId" required>
                                <option value="">请选择教学班</option>
                            </select>
                        </div>
                        <button type="submit" class="btn btn-primary">提交</button>
                    </form>
                </div>
            </div>
        </div>
    </div>

    <!-- 添加教学班模态框 -->
    <div class="modal fade" id="addClassModal" tabindex="-1">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">添加教学班</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
                </div>
                <div class="modal-body">
                    <div id="addClassMessage" class="alert alert-danger d-none"></div>
                    <form id="addClassForm">
                        <div class="mb-3">
                            <label for="classCourseId" class="form-label">课程编号</label>
                            <input type="text" class="form-control" id="classCourseId" required>
                        </div>
                        <div class="mb-3">
                            <label for="classTeacherId" class="form-label">教师ID</label>
                            <input type="text" class="form-control" id="classTeacherId" required>
                        </div>
                        <div class="mb-3">
                            <label for="classSemester" class="form-label">学期</label>
                            <input type="text" class="form-control" id="classSemester" placeholder="例如：2023-春季" required>
                        </div>
                        <div class="mb-3">
                            <label for="classTimeLocation" class="form-label">时间地点</label>
                            <input type="text" class="form-control" id="classTimeLocation" placeholder="例如：周二3-4节 教学楼B201" required>
                        </div>
                        <button type="submit" class="btn btn-primary">提交</button>
                    </form>
                </div>
            </div>
        </div>
    </div>

    <!-- 确认删除模态框 -->
    <div class="modal fade" id="confirmDeleteModal" tabindex="-1">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">确认删除</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
                </div>
                <div class="modal-body">
                    <p id="deleteConfirmText">确定要删除此项吗？此操作不可恢复。</p>
                    <input type="hidden" id="deleteType" value="">
                    <input type="hidden" id="deleteId" value="">
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-danger" id="confirmDeleteBtn">确认删除</button>
                </div>
            </div>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
    <script src="../js/config.js"></script>
    <script src="../js/admin.js"></script>
</body>
</html> 